<template>
    <div>
        <!-- 面包屑导航 -->
        <border-header second="权限管理" third="权限列表"></border-header>

        <!-- 卡片视图 -->
        <el-card>
            <el-table :data="rightsList" style="width: 100%" stripe border>
                <el-table-column type="index"></el-table-column>
                <el-table-column prop="authName" label="权限名称"></el-table-column>
                <el-table-column prop="path" label="路径"></el-table-column>
                <el-table-column label="权限等级">
                    <template slot-scope="scope">
                        <el-tag size="mini" v-if="scope.row.level==='0'">一级</el-tag>
                        <el-tag type="success" size="mini" v-else-if="scope.row.level==='1'">二级</el-tag>
                        <el-tag type="warning" size="mini" v-else>三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script>
import borderHeader from '@/components/BorderHeader.vue'
import http from '@/util/http'
export default {
  data () {
    return {
      rightsList: []
    }
  },
  components: {
    borderHeader
  },
  created () {
    this.getRightsList()
  },
  methods: {
    async getRightsList () {
      const { data: res } = await http.get('rights/list')
      if (res.meta.status !== 200) return this.$message.error('获取权限列表失败')
      this.rightsList = res.data
    }
  }
}
</script>
